<?php
/**
 * Created by PhpStorm.
 * User: SD
 * Date: 2018/9/10
 * Time: 15:09
 */

if (!function_exists(responseResult)) {
    /**
     * responseResult 返回值格式化
     *
     * @param array $data
     * @param int $status
     * @param string $message
     * @return \Illuminate\Http\JsonResponse
     */
    function responseResult($data = [], $status = 0, $message = '')
    {
        $defaultMsg = $status ? trans('common.error_status') : trans('common.success_status');
        $responseData = [
            'status' => $status,
            'message' => empty($message) ? $defaultMsg : $message,
            'result' => $data ?: [],
        ];
        return response()->json($responseData);
    }
}


